<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"/>
<%@ include file="/commons/jsp/taglibs.jsp"%>
<%@taglib prefix="frame" uri="http://www.framework.com/taglib"%>
       <div>
         <input type="hidden" name="projectId" value="${projectId}" id="projectId"/> 	       
         <div id="mydialog"></div>
         <div id="mydialog2"></div>            
       </div>
	    <script type="text/javascript">
	     var projectId=$("#projectId").val();
	    $(function(){   
	         $('#mydialog').datagrid({
	                     idField:'id',
	                     width:'985',
	                     height:'360',
                         url:'${ctx}/business/projectmanage/leader/getProjectBidList?projectId='+projectId+"&type=1",      
	                    // fitColumns:true,//自动填充宽度
	                     striped:true,//隔行变色
	                     loadMsg:"数据正在加载中.....",
	                     rownumbers:true,//显示序号
	                   //singleSelect:true,
	                     pagination:true,
	                     nowrap:false,                    
	                     pageSize:5,
	                     pageList:[10,15,20],
	                     columns:[[   
	                             {field:'ck',checkbox:true }, 
	      	                     {field:'pk',title:'单位名称',width:150,align:'center',formatter:fromatterCompanyName}, 
	      	                     {field:'biaoDuanNo',title:'项目标段号', align:'center',width:200},
	      				         {field:'tnAmount',title:'缴纳金额',width:100,align:'center'},
	      				         {field:'transTime',title:'缴纳时间',width:150,align:'center'},
	      				         {field:'hstSeqNum',title:'交易流水号', align:'center',width:100},
	      				         {field:'bid',title:'是否投标', align:'center',width:100,formatter:formatBid},
	      				         {field:'returnOpt',title:'是否提交退还申请', align:'center',width:100,formatter:formatOpt},
	      				         {field:'status',title:'退还状态', align:'center',width:140,formatter:formatStatus},
				         ]],
			         toolbar:[
			                {text:'退还保证金',iconCls:'icon-add',handler:function(){  			                    
                                     returnDeposit();
                                }  
                            },  
                           
                       ]     
			        });
		 });
	    // 是否投标格式化
	    function formatStatus(val, row, index){
	    	if (row.status == false) {
				return '<font color="red">未退还</font>';
					} else if (row.status == true) {
						return '<font color="green">已退还</font>';
	    }
	    	}
	    
	    //是否提交申请格式化	    
	     function formatOpt(val, row, index){
	    	if (row.returnOpt == false) {
				return  '<font color="red">未申请</font>';
					} else if (row.returnOpt == true) {
						return  '<font color="green">已申请</font>';
			       }
	        }
	    
	   //是否投标    
	     function formatBid(val, row, index){
	    	if (row.bid == false) {
				return '<font color="red">未投标</font>';
					} else if (row.bid == true) {
						return '<font color="green">已投标</font>';
			       }
	        }
	   
	     //单位名
	     function fromatterCompanyName(val, row, index){
		    	if(row.pk){
				  return row.pk.companyName;
		    	  }  
		        }
	    
	    
	    //退还保证金
	     function  returnDeposit(){
	    	 $.messager.confirm('确认对话框', '是否退还保证金？', function(r){
	    			if (r){
	    	    		var arr =$('#mydialog').datagrid('getSelections');
	    	    		 if(arr.length <1){
						     $.messager.show({
						        title:"提示信息",
						        msg:"请选择一条记录进行修改!"				        
						     });
						     return false;
						   }
	    				$.ajax({
	    					type:'post',
	    					url:'${ctx}/business/projectmanage/leader/returnDeposit',
	    					data:{
	    						  projectId:arr[0].pk.projectId,
	    						  projectName:null,
	    						  bidderName:arr[0].pk.companyName,
	    						  bidderId:arr[0].bidderId
	    						   },
	    					success:function(data){
	    						if(data=="saveSuccess"){
	    							$.messager.alert('提示信息','提交退还申请成功!', 'info',function(){
	    								 $('#mydialog').datagrid('reload');
	    							});
	    						}else{
	    							$.messager.alert('提示信息','提交退还申请无响应!', 'info');
	    						}
	    						 
	    					}
	    				});
	    			}
	    		});


	    }
		

       </script>

                 
   
  
